package com.fenxiangle.yueding.feature.mine.view.adapter;

import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.fenxiangle.yueding.R;
import com.fenxiangle.yueding.entity.VedioShowType;
import com.fenxiangle.yueding.entity.VedioType;
import com.fenxiangle.yueding.entity.bo.UserCenterBo;
import com.fenxiangle.yueding.entity.bo.UserVideoBo;
import com.suozhang.framework.framework.AM;

import java.util.List;

public class VedioAdapter extends BaseQuickAdapter<UserVideoBo, BaseViewHolder> {

    private boolean isAdd;

    public VedioAdapter(boolean isAdd) {
        super(R.layout.item_vedio);
        this.isAdd = isAdd;
    }

    private UserCenterBo userCenterBo;

    public void setUserCenterBo(UserCenterBo userCenterBo) {
        this.userCenterBo = userCenterBo;
    }

    @Override
    protected void convert(BaseViewHolder helper, UserVideoBo item) {
        helper.setVisible(R.id.btn_show_upload, TextUtils.isEmpty(item.getVideoCover()) && isAdd ? true : false)
                .setVisible(R.id.btn_show_video, !TextUtils.isEmpty(item.getVideoCover()) ? true : false)
                .setText(R.id.video_type, VedioType.getName(item.getVideoType()))
                .setText(R.id.btn_show_upload, VedioShowType.getName(helper.getLayoutPosition()))
                .setText(R.id.tv_title, TextUtils.isEmpty(item.getVideoDescribe())?"":item.getVideoDescribe())
                .addOnClickListener(R.id.btn_show_upload)
                .addOnClickListener(R.id.video_img)
                .addOnLongClickListener(R.id.video_img)
        ;


        if (!TextUtils.isEmpty(item.getVideoCover())) {
            ImageView imageView = helper.getView(R.id.video_img);
            AM.image().bind(item.getVideoCover(), imageView);
        }
        if (!TextUtils.isEmpty(userCenterBo.getUserHead())) {
            ImageView imageView = helper.getView(R.id.video_user_head);
            AM.image().bindToCircleObject(userCenterBo.getUserHead(), imageView);
        }

        if (item != null) {
            TextView video_creditScore = helper.getView(R.id.video_creditScore);
            TextView video_timeValue = helper.getView(R.id.video_timeValue);
            TextView video_fans = helper.getView(R.id.video_fans);
            video_creditScore.setText("信用分：" + userCenterBo.getCreditScore());
            video_timeValue.setText("￥" + userCenterBo.getTimeValue() + "/小时");
            video_fans.setText("粉丝（" + userCenterBo.getFans() + "）");

        }
    }
}
